
/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2022原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory.aot;

import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.RegisteredBean;
import org.springframework.lang.Nullable;

/**
 * AOT processor that makes bean registration contributions by processing
 * {@link RegisteredBean} instances.
 *
 * <p>{@code BeanRegistrationAotProcessor} implementations may be registered in
 * a {@value AotServices#FACTORIES_RESOURCE_LOCATION} resource or as a bean.
 *
 * <p>Using this interface on a registered bean will cause the bean <em>and</em>
 * all of its dependencies to be initialized during AOT processing. We generally
 * recommend that this interface is only used with infrastructure beans such as
 * {@link BeanPostProcessor} which have limited dependencies and are already
 * initialized early in the bean factory lifecycle. If such a bean is registered
 * using a factory method, make sure to make it {@code static} so that its
 * enclosing class does not have to be initialized.
 *
 * <p>An AOT processor replaces its usual runtime behavior by an optimized
 * arrangement, usually in generated code. For that reason, a component that
 * implements this interface is not contributed by default. If a component that
 * implements this interface still needs to be invoked at runtime,
 * {@link #isBeanExcludedFromAotProcessing} can be overridden.
 *
 * @author Phillip Webb
 * @author Stephane Nicoll
 * @since 6.0
 * @see BeanRegistrationAotContribution
 */
/**
 *AOT处理器，通过处理进行bean注册贡献
 *｛@link RegisteredBean｝实例。
 *
 *＜p＞｛@code BeanRegisterationAotProcessor｝实现可以在
 *｛@value AotServices#FACTORIES_RESOURCE_LOCATION｝资源或作为bean。
 *
 *＜p＞在注册的bean上使用此接口将导致bean＜em＞和</em>
 *在AOT处理期间初始化其所有依赖项。我们通常
 *建议此接口仅用于基础结构bean，例如
 *｛@link BeanPostProcessor｝具有有限的依赖关系
 *在bean工厂生命周期的早期初始化。如果注册了这样的bean
 *使用工厂方法，确保使其{@code static}
 *封闭类不必初始化。
 *
 *＜p＞AOT处理器用优化的
 *排列，通常在生成的代码中。因此
 *默认情况下不提供此接口。如果组件
 *实现该接口仍然需要在运行时调用，
 *｛@link#isBeanExcludedFromAotProcessing｝可以被重写。
 *
 *@作者Phillip Webb
 *@作者Stephane Nicoll
 *@自6.0起
 *@see BeanRegisterationAotContribution
 */
@FunctionalInterface
public interface BeanRegistrationAotProcessor {

	/**
	 * Process the given {@link RegisteredBean} instance ahead-of-time and
	 * return a contribution or {@code null}.
	 * <p>
	 * Processors are free to use any techniques they like to analyze the given
	 * instance. Most typically use reflection to find fields or methods to use
	 * in the contribution. Contributions typically generate source code or
	 * resource files that can be used when the AOT optimized application runs.
	 * <p>
	 * If the given instance isn't relevant to the processor, it should return a
	 * {@code null} contribution.
	 * @param registeredBean the registered bean to process
	 * @return a {@link BeanRegistrationAotContribution} or {@code null}
	 */
	/**
	 *提前处理给定的｛@link RegisteredBean｝实例，并
	 *返回贡献或｛@code null｝。
	 *＜p＞
	 *处理器可以自由使用他们喜欢的任何技术来分析给定的
	 *实例。大多数通常使用反射来查找要使用的字段或方法
	 *在捐款中。贡献通常生成源代码或
	 *AOT优化应用程序运行时可以使用的资源文件。
	 *＜p＞
	 *如果给定实例与处理器无关，则应返回
	 *｛@code null｝贡献。
	 *@param registeredBean要处理的注册bean
	 *@return一个｛@link BeanRegistryAotContribution｝或｛@code null｝
	 */
	@Nullable
	BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean);

	/**
	 * Return if the bean instance associated with this processor should be
	 * excluded from AOT processing itself. By default, this method returns
	 * {@code true} to automatically exclude the bean, if the definition should
	 * be written then this method may be overridden to return {@code true}.
	 * @return if the bean should be excluded from AOT processing
	 * @see BeanRegistrationExcludeFilter
	 */
	/**
	 *返回与此处理器关联的bean实例是否应为
	 *排除在AOT处理本身之外。默认情况下，此方法返回
	 *｛@code true｝自动排除bean，如果定义应该
	 *则可以重写此方法以返回｛@code true｝。
	 *@return如果应该从AOT处理中排除bean
	 *@参见BeanRegistryExcludeFilter
	 */
	default boolean isBeanExcludedFromAotProcessing() {
		return true;
	}

}
